<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>我的预约</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		<script src="js/rem_750.js"></script>
	</head>
	<body>
		
		<div class="myCont">
			<div class="myTitle">
				<h3>我的预约:</h3>
			</div>
			<!-- 预约内容 -->
			<div class="myPeople no_report" style="display: none;">
				没有记录
			</div>
			<!--  有记录的返回-->
			<div class="scroll">
				<!-- <div class="myPeople">
					<div class="myname">
						<p>名字:代用名</p>
					</div>
					<div class="report_day_time">
						<p>日期:2019-09-28</p>
					</div>
					<div class="mytime">
						<p>场次:2020-02-02</p>
					</div>
				</div> -->
				
			</div>
			
			<a href="./index.html">返回首页</a>
		</div>
	<script src="js/jquery.js"></script>
	<script src="js/util.js"></script>
	<script src="js/api.js"></script>
	<script type="text/javascript">
		$(function(){
			var show_list = ["-","09:00-12:00","12:00-14:30","14:30-17:00"]
			var phone_num = getQueryString("phone");
			var uname = getQueryString("uname");
			var access_token = getQueryString("access_token");
			
			// 数据请求
			$.ajax({
				method:"post",
				url:api.report,
				data:{
					phone_num:phone_num,
					uname:uname
				},
				dataType:"json",
				timeout:3000,
				success:function(res){
					console.log("成功")
					console.log(res);
					var result = res.res;
					if(result == 1){
						var report = res.data.report;
						var str = "";
						var uname = res.data.uname;
						report.forEach(function(ele){
							str += `<div class="myPeople" data-show_id=${ele.show_id}>
					                    <div class="myname">
						                    姓名:<span>${uname}</span>
					                    </div>
					                    <div class="report_day_time">
						                    日期:<span>${ele.day_time}</span>
					                    </div>
					                    <div class="mytime">
						                    场次:<span>${show_list[ele.show_id]}</span>
					                    </div>
				                    </div>`
						})
						$(".scroll").append(str).show();
						$(".no_report").hide();
						// 事件的委托
						$(".myPeople").click(function(event){
							var show_id = $(this).attr("data-show_id");
							var day_time = $(this).find(".report_day_time").find("span").text().trim();
	location.href=`./identity.html?access_token=${access_token}&show_id=${show_id}&day_time=${day_time}&uname=${escape(uname)}`
						})
					}
				},
				error: function() {
					swal("数据请求异常")
				}
			})
		})
		
	</script>
	</body>
</html>
